#ifndef TIME_ASPECT_H
#define TIME_ASPECT_H

#include <utility>

#include "log/log.h"
#include "Aspect.h"
#include "timer/timer.hpp"

namespace Canon {

class TimeCal
{
public:
    void Before()
    {
        LOG_WARN("[TimeCal] Start exec func %s", m_type.c_str());
        t.reset();
    }

    void After()
    {
        int64_t runTime = t.elapsed_nano();
        LOG_WARN("[TimeCal] Exec end, the func %s run time: %ld (us)",
                 m_type.c_str(), runTime / 1000);
    }

    void SetType(const std::string& type) { m_type = "[" + type + "]"; }

private:
    Timer::Timer t;
    std::string m_type;
};

} // namespace Canon

#endif